package com.azdebugit.list.arraylist.test.demo;

import java.util.ArrayList;
        import java.util.List;
        import java.util.stream.Collectors;

public class StudentDemo {

    public List<StudentTwo> streamForNewList() {

        List<StudentOne> list = new ArrayList<StudentOne>();


        StudentOne one = new StudentOne("第一", "北京", 12);
        StudentOne two = new StudentOne("第二", "上海", 15);
        StudentOne three = new StudentOne("第三", "南京", 9);

        list.add(one);
        list.add(two);
        list.add(three);

        List<StudentTwo> newList = list.stream().map(e -> new StudentTwo(e.getName(), e.getCity())).collect(Collectors.toList());

        return newList;
    }
}